<template>
	<view class="content" :style="'background-image: url(' + $c.config.media + 'yuemini/reg_bg.png);'">
		<view class="top" :style="`margin-top:`+heigh + `px`">
			<view class="top-icon"   @click="back">
				<image class="img"
					:src="$c.config.imageIP + 'yuemini/ic_back.png'"
					mode="aspectFill"></image>
			</view>
			<view class="top-title" >{{title}}</view>
		</view>
		<c-gap height="32px"></c-gap>
		<view class="body" >
			<!-- 	<view class="user">
					<view class="avatar">
						<image class="img" mode="aspectFill" :src="info.user.pic"></image>
					</view>
					<text>您尚未开通vip</text>
				</view> -->
				<view class="warp">
					<view class="overtime-line" :style="'background-image: url(' + $c.config.media + 'yuemini/vipbg.png);'">
						<c-gap height="218rpx" />
						<view class="vip-time" v-if="info.user.isVip">
							<view class="vip-date" v-if="info.user.isVip">{{ info.user.vipEndDate }}到期</view>
						</view>
						<view class="vip-time" v-else>
							<view class="vip-date">非会员</view>
						</view>
					</view>
					<c-gap height="32rpx" />
					<view class="selling-point">
						<view class="selling-point-item" v-for="item in sellingItems" :key="item.name">
							<view class="item-title">
								{{ item.name }}
							</view>
							<view class="desc">
								{{ item.desc }}
							</view>
						</view>
					</view>
				
				
					<c-gap height="50rpx" />
					<view class="vip-h2">选择套餐</view>
					<c-gap height="12rpx" />
					<view class="price">
						<view class="price-item" v-for="(item, index) in info.list"  @click="changeItme(item)" :key="index"
							 :class="selectItem.id == item.id ? 'active' : ''">
							<view class="">
								<view class="name" :class="selectItem.id == item.id ? 'active' : ''">
									￥{{item.priceDay}}/天
								</view>
								<c-gap height="30rpx" />
								<view class="desc" :class="selectItem.id == item.id ? 'active' : ''">
									<!-- {{item.num}}{{7==item.num? '天': '月'}} -->
									{{monthText(item)}}
								</view>
							</view>
							<view class="title" :class="selectItem.id == item.id ? 'active' : ''">￥{{item.price}}
							</view>
						</view>
					</view>
					<c-gap height="118rpx" />
					<view class="vip-kaitong" @click="open">立即开通</view>
					<c-gap height="238rpx" />
				</view>
				
	<!-- 			<view class="title">会员特权</view>
				<view class="icon-list">
					<view class="icon-item">
						<image class="img" mode="aspectFill" src="./img/vip_icon1.png"></image>
						<text>免费畅聊</text>
					</view>
					<view class="icon-item">
						<image class="img" mode="aspectFill" src="./img/vip_icon2.png"></image>
						<text>会员专属色</text>
					</view>
					<view class="icon-item">
						<image class="img" mode="aspectFill" src="./img/vip_icon3.png"></image>
						<text>查看谁看过我</text>
					</view>
					<view class="icon-item">
						<image class="img" mode="aspectFill" src="./img/vip_icon4.png"></image>
						<text>会员专属标识</text>
					</view>
					<view class="icon-item">
						<image class="img" mode="aspectFill" src="./img/vip_icon5.png"></image>
						<text>会员专属气泡</text>
					</view>
					<view class="icon-item">
						<image class="img" mode="aspectFill" src="./img/vip_icon6.png"></image>
						<text>专属VIP客服</text>
					</view>
				</view> -->
			<!-- 	<view class="title" >会员开通</view>
				<view class="list">
					<view @click="changeItme(item)"  class="item" :class="selectItem.id == item.id ? 'on' : ''" v-for="(item,index) in info.list">
						<view style="position: absolute; left:10rpx; top:10rpx; font-size: 26rpx;">{{item.num}}个月</view>
						<view style="position: absolute; left:10rpx; top:80rpx; font-size: 36rpx; color: red;">￥{{item.priceDay}}/天</view>
						<view style="position: absolute; left:10rpx; bottom:10rpx; font-size: 20rpx;">￥{{item.price}}</view>
						<view style="position: absolute; right:0rpx; bottom:0rpx; color:#fff; font-size: 20rpx; background-color: red; padding: 5rpx 10rpx; border-radius: 20rpx;">{{item.strKey}}</view>
					</view>
				</view> -->
		<!-- 		<view  class="button" @click="open">
				<span v-if="selectItem.id != 0">￥{{selectItem.price}}</span>
				立即开通</view> -->
				<uni-popup ref="popup" type="center">
					<m-pay :money="selectItem.price" :projectId="selectItem.id" :type="2"></m-pay>
				</uni-popup>
			</view>
	</view>
</template>

<script>
import CGap from '@/components/c-gap.vue';
	import {to} from '@/utils/index.js';
	 import Mpay from '@/components/m-pay/m-pay.vue';
	 const app = getApp();
	export default {
		components: {
		CGap
		},
		data() {
			return {
				$c: this.$c,
				heigh:50,
				title: '会员中心',
				name:'',
				sellingItems: [{
						name: '看得更多',
						desc: '查看用户再无次数限制'
					},
					{
						name: '看得更爽',
						desc: '迅速提升人气'
					},
					{
						name: '看得更久',
						desc: '阅后即焚查看提至6s'
					},
					{
						name: '看得更省',
						desc: '免费畅聊解锁社交账号'
					}
				],
				info: {
					user:{pic:''},
					list:[]
				},
				selectItem: {
					id: 0
				}
			}
		},
		onLoad(option) {
			// #ifdef APP-PLUS
			this.heigh = this.$store.state.StatusBar.statusBar; 
			// #endif
			
		},
		onShow(options){
			this.getInfo();
		   
		},
		methods: {
			to,
			back(){
				to()
			},
			monthText(item) {
				let text = '月会员'
				if (3 == item.num) {
					text = '季会员'
				} else if (6 == item.num) {
					text = '半年会员'
				} else if (7 == item.num) {
					text = '七天会员'
				} else if (12 == item.num) {
					text = '年会员'
				}else if (24 == item.num) {
					text = '2年会员'
				}
				return text;
			},
			open(){
				if(this.selectItem.id <= 0){
					uni.showToast({
						title: "请选择开通时间",
						icon: "none"
					})
				}
				this.$refs.popup.open()
			},
			async getInfo(){
				let res = await this.$c.post("/app/vip/list")
				if(res.code != 0){
					
				}
				for(let i in res.data.list){
					let item = res.data.list[i]
					if(this.selectItem.id == 0){
						this.selectItem = item
					}
				}
				console.log(this.info)
				this.info = res.data
			},
			changeItme(item)
			{
				this.selectItem = item
			},
			async submit(){
				let res = await this.$c.post("/app/exchange/exchange?id="+item.id)
				if(res.code != 0){
					uni.showToast({
						title: res.msg,
						icon: "none"
					})
					return;
				}
				uni.showToast({
					title: "兑换成功",
					icon: "none"
				})
				setTimeout(()=>{
					this.getInfo()
				},1000)
			}
		}
	}
</script>

<style scoped lang="scss">
	.content{
		width: 750rpx;
		min-height: 100vh;
		background-size: 750rpx 100vh;
		background-position: 0 0;
	}
	.page {
		width: 100vw;
		padding:30rpx;
		height: 100vh;
		background: linear-gradient(#e3ecfb, #fdedf0, #fff, #fff);
		transform: translateX(-30rpx);
	}
	.top {
		position: fixed;
		top: 0rpx;
		width: 100%;
		background:none ;
		z-index: 999;
		text-align: center;
		vertical-align: middle;
		padding:10rpx;
	}
	.top-icon {
		position: absolute;
		left: 30rpx;
		z-index: 99;
		width: 30rpx;
		height: 30rpx;
	}
	.top-title {
		line-height: 50rpx;
		display: block;
		height:50rpx;
		z-index: 99;
		color: #fff;
	}

	.body{
		padding-top:40rpx;
		.user{
			text-align: center; 
			.avatar{
				width:80rpx;
				height:80rpx;
				// position:absolute;
				// left:50%;
				margin-left:50%;
				transform: translateX(-50%);
				border-radius: 50%;
				overflow: hidden;
				margin-bottom: 20rpx;
				margin-top: 20rpx;
			}
			text{
				color: #00c8c8;
				font-size:24rpx;
			}
		}
		.title{
			color: #ffaa7f;
			text-align: center;
			margin:20rpx;
			margin-top:80rpx;
		}
		.button{
			background-color: #e6bd9a;
			color:#fff;
			padding:10rpx 30rpx;
			height:60rpx;
			border-radius: 30rpx;
			font-size:34rpx;
			line-height: 60rpx;
			width:80%;
			margin: 0 auto;
			text-align: center;
			margin-top:300rpx;
		}
		.icon-list{
			margin-top:40rpx;
			margin-bottom:40rpx;
			height:400rpx;
			width:100%;
			.icon-item{
				width:calc(80%/3);
				margin-top:30rpx;
				margin-bottom:30rpx;
				margin-left:2%;
				margin-right:2%;
				float:left;
				text-align: center;
				background-color: rgba(255, 255, 255, 0.1);
				border-radius: 30rpx;
				image{
					width: 60rpx;
					height:60rpx;
				}
				text{
					display: block;
					color: #B2B2B2;
				}
			}
		}
		.list{
			margin-top:20rpx;
			.on{
				// background-color: #ffaa7f;
				background: linear-gradient(
				127deg, #FFF4DE 0%, #FFE6BA 100%, #FFE6BA 100%);
				color:#fff;
			}
			.item{
				border-radius: 20rpx;
				border: 1px solid #ffaa7f;
				width:26%;
				height:200rpx;
				float:left;
				margin-left:5%;
				margin-top:30rpx;
				position:relative;
			}
		}
	}
	.content {
		width: 750rpx;
		min-height: 100vh;
		background-size: 750rpx 100vh;
		//background-repeat: no-repeat;
		background-position: 0 0;
	
		.warp {
			width: 702rpx;
			margin: 0 auto;
	
			.nav-bar {
				display: flex;
				font-weight: 550;
				font-size: 34rpx;
				color: #fff;
	
				.title {
					width: 680rpx;
					text-align: center;
				}
			}
	
	
			.overtime-line {
				width: 694rpx;
				height: 322rpx;
				margin: 0 auto;
				background-size: 694rpx 322rpx;
				background-repeat: no-repeat;
				background-position: 0 0;
	
				.vip-time {
					.vip-date {
						height: 24rpx;
						font-size: 24rpx;
						font-weight: 500;
						color: #351980;
						line-height: 24rpx;
						margin-left: 32rpx;
					}
				}
			}
	
	
			.selling-point {
				display: flex;
				flex-wrap: wrap;
				justify-content: space-around;
	
				.selling-point-item {
					margin-top: 20rpx;
					width: 160rpx;
					height: 200rpx;
					background: rgba(255, 255, 255, 0.1);
					border-radius: 24rpx;
					padding: 20rpx;
					box-sizing: border-box;
					display: flex;
					flex-direction: column;
	
					justify-content: space-around;
	
					.item-title {
	
						height: 24rpx;
						font-size: 28rpx;
						font-weight: 550;
						color: #FFFFFF;
						line-height: 24rpx;
	
					}
	
					.desc {
	
						font-size: 24rpx;
	
						font-weight: 400;
						color: #B2B2B2;
						line-height: 28rpx;
						text-align: center;
					}
				}
			}
	
			.vip-h2 {
	
				height: 44rpx;
				font-size: 32rpx;
	
				font-weight: 550;
				color: #FFFFFF;
				line-height: 44rpx;
			}
	
			.price {
				display: flex;
				flex-direction: row;
				flex-wrap: wrap;
				justify-content: space-around;
	
				.price-item.active {
	
					background: linear-gradient(127deg, #FFF4DE 0%, #FFE6BA 100%, #FFE6BA 100%);
	
				}
	
				.price-item {
					margin-top: 20rpx;
					// margin-right: 10rpx;
					// margin-left: 10rpx;
					border-radius: 24rpx;
	
					display: flex;
					justify-content: space-between;
					align-items: center;
	
					width: 330rpx;
					height: 148rpx;
					background: rgba(255, 255, 255, 0.1);
					border-radius: 24rpx;
					padding: 20rpx;
					box-sizing: border-box;
	
					.name {
	
						height: 24rpx;
						font-size: 20rpx;
						font-weight: 400;
						color: #fff;
						line-height: 24rpx;
					}
	
					.title.active,
					.desc.active,
					.name.active {
						color: #a14617;
					}
	
					.title {
						height: 24rpx;
						font-size: 40rpx;
						font-weight: 600;
						color: #ffebc7;
						line-height: 24rpx;
					}
	
					.desc {
						height: 48rpx;
						font-size: 20rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #a4a4a4;
						line-height: 24rpx;
					}
				}
			}
	
	
	
			.vip-kaitong {
				margin: 0 auto;
				text-align: center;
				line-height: 120rpx;
				color: #a14617;
				width: 552rpx;
				height: 120rpx;
				background: linear-gradient(127deg, #FFF4DE 0%, #FFE6BA 100%, #FFE6BA 100%);
	
				border-radius: 60rpx;
			}
		}
	}

</style>